const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shop_id:'',
    items: [
      { name: 'week_0', value: '星期日','checked':''},
      { name: 'week_1', value: '星期一'},
      { name: 'week_2', value: '星期二' },
      { name: 'week_3', value: '星期三' },
      { name: 'week_4', value: '星期四' },
      { name: 'week_5', value: '星期五' },
      { name: 'week_6', value: '星期六' },
    ],
    value:[],
  },
  backto: function (e) {
    wx.navigateBack({})
  },
  onLoad:function(options){
    let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
    this.setData({
      token: extConfig.appid
    })
    var that = this;
    that.setData({
      shop_id:options.shop_id
    });
    wx.request({
      url: 'https://www.58zltc.com/api.php/Shop/memberday?token=' + that.data.token,
      data: {
        shop_id: options.shop_id
      },
      method: 'POST',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (t) {
        that.setData({
          item: t.data
        });
      }
    })


  },
  checkboxChange: function (e) {
    var that=this;
    that.setData({
      value: e.detail.value
    });
    
  },
  submit:function(){
    var that = this;
    var value = that.data.value;
    var shop_id = that.data.shop_id;
    wx.request({
      url: 'https://www.58zltc.com/api.php/Shop/edirMemberDay?token=' + that.data.token,
      data: {
        shop_id: shop_id,
        value:value
      },
      method: 'POST',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (t) {
        that.setData({
          item: t.data
        });
        wx.showToast({
          title: '修改成功',
        })
      }
    })
  }
})